/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jmodcog2.featuremap.som;

/**
 *
 * @author Mitch
 */
public class SOM2DRunner extends SOMRunner {
    
    protected final int input_w, input_h;
    protected final int kern_w, kern_h;


    
    
    
    
    @Override
    protected int win_index(int input_n) {
        int in_i = this._get2D_i(input_n, input_h);
        int in_j = this._get2D_j(input_n, input_h);
        
        int k_i = kern_i(in_i);
        int k_j = kern_j(in_j);
        int k_k = kern_k(in_i, in_j);
        
        return 2 * _get3D_n(k_i, k_j, k_k, input_h/kern_h, kern_w * kern_h);
    }
    
    protected int kern_i(int in_i) {
        return in_i/kern_w;
    }
    protected int kern_j(int in_j) {
        return in_j/kern_h;
    }
    
    protected int kern_k(int in_i, int in_j) {
        return (in_i % kern_w) * kern_h + (in_j % kern_h);
    }
    
    
    
}
